#!/bin/bash
set -x
CUR_DIR=`pwd`
BINARY_PATH=`dirname $0`
if [ ! -f $BINARY_PATH/`basename $0` ];then
	BINARY_PATH=`which $0`;
fi
echo "I am here:$BINARY_PATH"

if [ -d $1 ];then
	cd $1
	zip -rqv $CUR_DIR/tmp_unsigned.zip *
	cd $CUR_DIR
else
    cp -f $1 $CUR_DIR/tmp_unsigned.zip
fi

java -Xmx2048m -jar $BINARY_PATH/signapk.jar -w $BINARY_PATH/testkey.x509.pem $BINARY_PATH/testkey.pk8 $CUR_DIR/tmp_unsigned.zip $2
rm -f $CUR_DIR/tmp_unsigned.zip
set +x
